package com.naza.rpc.register;

import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.exception.NacosException;

import java.util.Properties;

public class NacosPublishConfigDemo {
    public static void main(String[] args) {
        try {
            // 初始化配置服务，控制台通过示例代码自动获取下面参数
            String serverAddr = "localhost:8848";
            String dataId = "test.data";
            String group = "group1";
            Properties properties = new Properties();
            properties.put("serverAddr", serverAddr);
            ConfigService configService = NacosFactory.createConfigService(properties);
            boolean isPublishOk = configService.publishConfig(dataId, group, "content");
            System.out.println(isPublishOk);
        } catch (NacosException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
